package com.xb.system.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.cache.MapCache;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.xb.model.domain.CompanyData;
import com.xb.system.listener.ExcelDataThreadPoolListener;
import com.xb.system.service.IOExcel;
import com.xb.system.service.UsersService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.InputStream;


/**
 * @author wjh
 * @create 2024-07-19 16:21
 */
@Service
public class IOExcelImpl implements IOExcel {
    
    @Resource
    private UsersService usersService;

    @Value("${path.output}")
    private String outputFilePath;
    
    @Value("${excel.headRowNumber:1}")
    private int headRowNumber;

    @Override
    public void inputExcel(InputStream inputput, String originalFilename) {
        ExcelReader build = EasyExcel.read(inputput, CompanyData.class, new ExcelDataThreadPoolListener(usersService, outputFilePath + originalFilename)).readCache(new MapCache()).headRowNumber(headRowNumber).build();
        ReadSheet sheet1 = EasyExcel.readSheet("Sheet1").build();
        build.read(sheet1);

    }


}
